package com.lyf.boot.config;

import com.lyf.boot.service.ISmsConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.sms4j.core.datainterface.SmsReadConfig;
import org.dromara.sms4j.provider.config.BaseConfig;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Luyufan
 * @date 2023/9/18 9:55
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class Sms4jReadConfig implements SmsReadConfig {

    private final ISmsConfigService smsConfigConfigService;

    @Override
    public BaseConfig getSupplierConfig(String configId) {
        log.debug("获取配置");
        if(null == smsConfigConfigService){
            throw new SecurityException("请实现ISmsConfigConfigService");
        }
        return smsConfigConfigService.getSupplierConfig(configId);
    }

    @Override
    public List<BaseConfig> getSupplierConfigList() {
        log.debug("加载所有配置");
        if(null == smsConfigConfigService){
            throw new SecurityException("请实现ISmsConfigConfigService");
        }
        //从接口里查询
        return smsConfigConfigService.getSupplierConfigList();
    }
}
